Strict

'@build	bmx makeapp (-x [to run after build]) -r -o (-a [if not quick build]) "php.test2.exe" "php.test2.bmx"
'@note	Or just use MaxIDE, MaxIDE Community Edition, MaxIDE X, BLide, or any other IDE you want.

Import nrgsMonkeyLib.php

Function Main:Int()
	Print "php Test 2~n"
	
	'/// Base conversion Tests
	Print bindec( "110011" )
	Print bindec( "000110011" )
	Print bindec( "111" )
	
	Print decbin( 51 )
	Print decbin( 7 )
	
	Print dechex( 10 )
	Print " hexdec: " + hexdec( "FGE" )
	
	' Misc Functions Tests
	If ( empty( "" ) )
		Print "~nString is empty"
	End
	
	Print rtrim( "~nWhy do you hate spaces!?    ~r    ~0 "  + chr(11) + "       ~n    " ) + "<-- No spaces!"
	Print rtrim( "Spaces aren't the only thing! -->ABCDEF", "ABCDEF" )
	Print rtrim( "String that doesn't need to be trimmed and doesn't loose any text" )
	
	Print "~nrtrim, ltrim, and trim/btrim - Examples"
	
	Local text:String, binary:String, hello:String
	text = "~t~tThese are a few words :) ...  "
	binary = chr(9) + "Example string" + chr(10)
	hello = "Hello World"
	
	Print "~q" + text + "~q"
	Print "~q" + binary + "~q"
	Print "~q" + hello + "~q"
	Print "~q" + rtrim( text ) + "~q"
	Print "~q" + rtrim( text, " ~t." ) + "~q"
	Print "~q" + rtrim( hello, "Hdle" ) + "~q"
	'Print rtrim( binary ) ' Can't be replicated at the moment
	Print "~q" + ltrim( text ) + "~q"
	Print "~q" + ltrim( text, " ~t." ) + "~q"
	Print "~q" + ltrim( hello, "Hdle" ) + "~q"
	'Print ltrim( binary ) ' Can't be replicated at the moment
	Print "~q" + trim( text ) + "~q"
	Print "~q" + trim( text, " ~t." ) + "~q"
	Print "~q" + trim( hello, "Hdle" ) + "~q"
	
	Print "~nString Split Tests~n"
	
	Local tString:String[] = str_split( "Hello World", 2 )
	For Local cnt:Int = 0 To tString.Length - 1
		Print cnt + ": " + tString[cnt]
	Next
	
	tString = str_split( "Hello World", 3 )
	For Local cnt:Int = 0 To tString.Length - 1
		Print cnt + ": " + tString[cnt]
	Next
	
	tString = str_split( "Hello World", 4 )
	For Local cnt:Int = 0 To tString.Length - 1
		Print cnt + ": " + tString[cnt]
	Next
	
	tString = str_split( "Hello World", 5 )
	For Local cnt:Int = 0 To tString.Length - 1
		Print cnt + ": " + tString[cnt]
	Next
	
	Return 0
End
